#include <iostream>
#include <stack>

using namespace std;
bool isBracket(char c){
    return c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' || c == '<' || c == '>';
}

bool isMatching(char o, char c){
    return (o == '(' && c == ')' )||(o == '[' && c ==']')||(o == '{' && c =='}')||(o == '<' && c =='>');
}

int main()
{
    cout <<"Введите скобочную последовательность: ";
    string sequence;
    getline(cin, sequence);
    stack<char> br;
    for(char bracket:sequence)
    {
        if (!isBracket(bracket)) continue;
        if (!br.empty() && isMatching(br.top(), bracket))
     {
         br.pop();
        }
        else
        {
            br.push(bracket);

        }
    }
    if(br.empty()){
        cout << "True";
     }
     else{
        cout << "False";
     }
}
